package jtk.project4.fleet.ibatis.dao;

import java.sql.SQLException;
import java.util.List;
import jtk.project4.fleet.domain.RbTable;

public class RbTableDao extends IbatisDao{
	
	public List selectRbTables() throws SQLException {
		return getSqlMap().queryForList("SELECT_ALL_RBTABLE", null);
	}
	
	public int updateRbTable(RbTable rbtable) throws SQLException{
		return (int) getSqlMap().update("UPDATE_RBTABLE", rbtable);
	}
	
	public int deleteRbTable(RbTable rbtable) throws SQLException{
		return (int) getSqlMap().delete("DELETE_RBTABLE", rbtable);
	}
	
	public RbTable insertRbTable(RbTable rbtable) throws SQLException{
		return (RbTable) getSqlMap().insert("INSERT_RBTABLE", rbtable);
	}
	
	public RbTable insertRbTablerType(RbTable rbtable) throws SQLException{
		return (RbTable) getSqlMap().insert("INSERT_RBTABLE_TYPE", rbtable);
	}
	
	public String selectRbTableType(String ID) throws SQLException {
		return (String) getSqlMap().queryForObject("SELECT_RBTABLE_TYPE", ID);
	}
	public static void main(String[] args) throws SQLException{
		RbTable rbtable  = new RbTable();
		List<RbTable> rbtables ;
		
		//rbtable.setTableName("riska"); 
		//new RbTableDao().deleteRbTable(rbtable); 
		//System.out.println("Tabel dengan nama "+rbtable.getTableName()+ " ,telah di hapus dari DB");
		
		//rbtable.setTableName("kinjit");
		
		//new RbTableDao().insertRbTable(rbtable);
		//System.out.println("TableName bernama '"+rbtable.getTableName()+ "' telah di insert ke DB");
		
		//rbtables = new RbTableDao().selectRbTables(); 
		//System.out.println("jumlah record yang ada ialah "+rbtables.size());
		
		new RbTableDao().selectRbTableType("sanyo");
		System.out.println("TableName bernama "+rbtable.getTableName()+ " ,telah di dapat pada dari DB dengan TableAlias ="+ rbtable.getTableAlias());
		
		//rbtable.setTableAlias("sari"); 
		//new RbTableDao().updateRbTable(rbtable);
		//System.out.println(" xx "+rbtable.getTableName()+ " ,telah diupdate");
		
	}
}